﻿
/*
EC-IDE class, from default dom template,
	AppEntry
	AppEntry

Author:

All Rights Reserved

LICENSE:

Created: 2008-11-06 09:57:35

Updated:

*/

//#EC_PARAM {param:'n'}

$ec.$preload(
	"AppEntry",
	function()
	{
		//#EC_IMPORT
		var RuleJavascript=$ec.$import("org.supertree.editor.RuleJavascript").prototype;
		//#END_EC_IMPORT

		this.prototype= {
//////////////////////////////
// EC-CLASS BODY
//////////////////////////////
			
			eid: "",    //binding element id
			
			AppEntry: function( e, p )  //ec-class constructor
			{
				this.eid= $ec.$eid(e);      //assign and get unique element id
				

				var o=$ec($ec(e,"editor"));
				o.AddRule( RuleJavascript );
				//aaa
				o.SetRule( RuleJavascript );
				
				o.SetText("var a=0;\nif(a==0)\n{\n\ta=1;\n}\n");
			},
			
			ChkLineNumClick: function(evt)
			{
				var e= $ec(this.eid);
				var ei=$ec(e,"chkLineNum");
				var b=ei.checked;
				//alert(b);
				ei=$ec(e,"editor",ei);
				$ec(ei).SetLineNumber(b);
			},
			
			ChkWrapClick: function(evt)
			{
				var e= $ec(this.eid);
				var ei=$ec(e,"chkWrap");
				var b=ei.checked;
				//alert(b);
				ei=$ec(e,"editor",ei);
				$ec(ei).SetWrap(b);
			},
			


			
			ChkReadonlyClick: function(evt)
			{
				var e= $ec(this.eid);
				var ei=$ec(e,"chkReadonly");
				var b=ei.checked;
				//alert(b);
				ei=$ec(e,"editor",ei);
				$ec(ei).SetReadonly(b);
			},
			
			BtnGetTextClick: function(evt)
			{
				var e= $ec(this.eid);
				var ei=$ec(e,"editor");
				alert($ec(ei).GetText());
			},
			
			BtnSetTextClick: function(evt)
			{
				var e= $ec(this.eid);
				var s=window.prompt("",new Date);
				if(!s) return;
				var ei=$ec(e,"editor");
				$ec(ei).SetText(s);
			},
			
			ChkShowReturnClick: function(evt)
			{
				var e= $ec(this.eid);
				var ei=$ec(e,"chkShowReturn");
				var b=ei.checked;
				//alert(b);
				ei=$ec(e,"editor",ei);
				$ec(ei).SetLineBreak(b);
			},
			
			SelFontsizeChange: function(evt)
			{
				var e= $ec(this.eid);
				var e= $ec(this.eid);
				var ei=$ec(e,"selFontsize");
				var v=ei.value;
				//alert(b);
				ei=$ec(e,"editor",ei);
				$ec(ei).SetFontSize(parseInt(v));
			},
			
			ChkDisableBoldClick: function(evt)
			{
				var e= $ec(this.eid);
				var e= $ec(this.eid);
				var ei=$ec(e,"chkDisableBold");
				var v=ei.checked;
				//alert(b);
				ei=$ec(e,"editor",ei);
				$ec(ei).SetNoBold(v);
			}
			

			
//////////////////////////////
// END EC-CLASS BODY    //NOTE - DO NOT CHANGE THESE 3 LINES, the ide wizards may use them.
//////////////////////////////
		};
		
		//#EC_RES
		this.$res=["",0,"<table border=1><tr><td>\n\nTest<br>\n<input type=checkbox name='chkLineNum' checked>LineNum\n\n<input type=checkbox name=\"chkWrap\">Wrap (ie & readonly)\n\n<input type=checkbox name=\"chkReadonly\">Readonly\n\n<input type=checkbox name=\"chkShowReturn\">Show Line Break\n\n\n<select name=selFontsize>\n\t<option value=\"16\">16px\n\t<option value=\"14\">14px\n\t<option value=\"12\">12px\n</select>\n\n<input type=checkbox name=\"chkDisableBold\">Disable Bold Font\n\n\n<br>\n\n<button name=btnGetText>GetText</button>\n<button name=btnSetText>SetText</button>\n<hr>\n<div name=editor jclass=\"org.supertree.editor.SyntaxViewer{linenum:1,wrap:0,readonly:0,fontsize:16,debug:1,wrap:0,linebreak:0}\" style='width:500px;'></div>\n<hr>\n\n</td></tr></table>\n" ];
		//#END_EC_RES
		
		//#EC_MAP
		this.$map=[
			["chkLineNum","click","ChkLineNumClick"],
			["chkWrap","click","ChkWrapClick"],
			["chkReadonly","click","ChkReadonlyClick"],
			["btnGetText","click","BtnGetTextClick"],
			["btnSetText","click","BtnSetTextClick"],
			["chkShowReturn","click","ChkShowReturnClick"],
			["selFontsize","change","SelFontsizeChange"],
			["chkDisableBold","click","ChkDisableBoldClick"]
			];
		//#END_EC_MAP
		
	}
);
